#@tabLayout()

#define main()
<div style="">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 选课管理 <span class="c-gray en">&gt;</span> 选课列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="page-container">
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort" id="sc-table">
				<thead>
					<tr class="text-c">
						<th>课程编号</th>
						<th>课程名称</th>
						<th>任课教师</th>
						<th>学生姓名</th>
						<th>成绩</th>
						<th>操作</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
</div>
#end

#define js()
<script type="text/javascript">

var sc_table = $('#sc-table').DataTable({
	"processing": true,
	"serverSide": true,
	"ajax":"#(baseUrl)/sc/list",
	"columns": [
		{"data":"Course_ID",},
		{"data":"Course_name"},
		{"data":"Teacher_name"},
		{"data":"Student_name"},
		{"data":"Grade"},
		{
			"data":null,
			"render":function(data, type, full ,meta){
				var btn = #if(role==3)
						  '<a style="text-decoration:none" class="ml-5" onClick="sc_del(this,\''+full.Course_ID+'\',\''+full.Student_ID+'\')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>'+
						  #end
						  #if(role>=2)
						  '<a style="text-decoration:none" class="ml-5" onClick="sc_edit(this,\''+full.Course_ID+'\',\''+full.Student_ID+'\')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>'
						  #else
					      '';
						  #end
				return btn;
			}
		}
	]
});

/*选课-编辑*/
function sc_edit(title,Course_ID,Student_ID){
	var index = layer.open({
		type: 2,
		title: "编辑选课",
		content: "#(baseUrl)/sc/addPage?Student_ID="+Student_ID+"&Course_ID="+Course_ID,
		end:function(){
			sc_table.ajax.reload();
		}
	});
	layer.full(index);
}

/*选课-删除*/
function sc_del(obj,Course_ID,Student_ID){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '#(baseUrl)/sc/remove',
			data: {"Course_ID":Course_ID,"Student_ID":Student_ID},
			dataType: 'json',
			success: function(data){
				sc_table.ajax.reload();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
</script>
#end